package com.jmu.medicineknows.controller;

import com.jmu.medicineknows.dto.RoleMenuDto;
import com.jmu.medicineknows.dto.RoleQueryDto;
import com.jmu.medicineknows.entity.Result;
import com.jmu.medicineknows.entity.Role;
import com.jmu.medicineknows.entity.User;
import com.jmu.medicineknows.service.RoleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: JieZi
 * @Date: 2023/7/19 19:36
 * @Description:
 **/
@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @ApiOperation("角色列表")
    @PostMapping("/list")
    public Result list(@RequestBody RoleQueryDto dto){
        return roleService.list(dto);
    }

    @ApiOperation("更新/添加角色")
    @PostMapping("/update")
    public Result update(@RequestBody Role role){
        return roleService.update(role);
    }

    @ApiOperation("删除角色")
    @GetMapping("/delete/{id}")
    public Result delete(@PathVariable("id") Long id){
        return roleService.delete(id);
    }

    @ApiOperation("获取角色菜单")
    @GetMapping("/getRoleMenu/{id}")
    public Result getRoleMenu(@PathVariable("id") Long id){
        return roleService.getRoleMenu(id);
    }

    @ApiOperation("绑定角色和菜单")
    @PostMapping("/insertRoleMenu")
    public Result insertRoleMenu(@RequestBody RoleMenuDto dto){
        return roleService.insertRoleMenu(dto);
    }
}